// pages/createdaojishi/createdaojishi.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    daojishidates:"2021-4-25",
    roomname:null,
    colorList:[
      "111", 
      "#BB6A54", "#E1BEBE",
      "#BB6A54", "#DCC896",
      "#E2C9F1","#CFD66E",
      "#5594C7","#D3D3D1",
      "#B9696A",
      "#83A569","#9899B7",
      "#DDAE7A","#775D79"
    ]

  },

  cancelCreatedaojishi(){
    wx.switchTab({
      url: '../../pages/shouye/shouye',
    })
    },
  
  btnSubmit(res){//提交表单
    console.log(res)
    var daojishiname = res.detail.value.daojishiname;
    var colorint = Math.ceil(Math.random()*13);//获取1-11之间的整数  
    //console.log(daojishiname)
    if(daojishiname!=""){
      wx.cloud.callFunction({
        name:"createdaojishi",
        data:{
          daojishiname: daojishiname,
          daojishidate: this.data.daojishidates,
          color: this.data.colorList[colorint]
        }
      }).then(res=>{
        console.log(res)
      });
    }

    wx.switchTab({
      url: '../../pages/shouye/shouye',
    })
  },

  bindDateChange: function (e) {
    console.log(e)
    this.setData({
      daojishidates: e.detail.value
    })
  },

  onLoad: function (options) {
  var date = new Date().toISOString().substring(0, 10);
  //console.log(new Date())
  this.setData({
    daojishidates:date
  })
  //console.log(options)
  if(options.date!=null){
    this.setData({
      daojishidates:options.date,
      roomname:options.roomname
    })
  }
  
  },

  onReady: function () {

  },

  onShow: function () {

  },

  onHide: function () {

  },


  onUnload: function () {

  },


  onPullDownRefresh: function () {

  },


  onReachBottom: function () {

  },


  onShareAppMessage: function () {

  }
})